/*
A Changer
control_A
title_A
trigger_A
score_A





*/


while {true} do {
sleep dure_cap;
//////////////////// ACTIF //////////////////////////////////////////////////////////////
if (control_B == -1) then { // Zone B sous control DEF
cap_active_A = true;
_type = getMarkerType "title_A"; if (_type != "selector_selectedMission") then {"title_A" setMarkerType "selector_selectedMission"};
};
////////////////////////////////////////////////////////////////////////////////////////

//////////////////// BLOQUER //////////////////////////////////////////////////////////
if (control_B == 0) then { // Zone B neutre
cap_active_A = false;
_type = getMarkerType "title_A"; if (_type != "selector_selectable") then {"title_A" setMarkerType "selector_selectable"};
};
////////////////////////////////////////////////////////////////////////////////////////

//////////////////// VERROUILLER ///////////////////////////////////////////////////////
if ((control_A == 1) && (control_B == 1)) then { // A et B sous control ATT
cap_active_A = false;
score_A = 100;
_color = getMarkerColor "zone_A"; if (_color != "ColorBlue") then {"zone_A" setMarkerColor "colorBlue"};
_color = getMarkerColor "title_A"; if (_color != "ColorBlue") then {"title_A" setMarkerColor "colorBlue"};
_type = getMarkerType "title_A"; if (_type != "mil_box") then {"title_A" setMarkerType "mil_box"};
};
////////////////////////////////////////////////////////////////////////////////////////

//////////////////// BLEED /////////////////////////////////////////////////////////////
if (control_A == -1) then { // Zone A sous control DEF
cap_active_A = true;
ticket_att = ticket_att - dure_cap;
if (ticket_att <= 0) then {att_lose = true};
_type = getMarkerType "title_A"; if (_type != "FireMission") then {"title_A" setMarkerType "FireMission"};
};
////////////////////////////////////////////////////////////////////////////////////////


//////////////////// Script Cap /////////////////////////////////////////////////////////////
if (cap_active_A) then {

	// Qui controle ?
	
	// Zone Neutre
	if (control_A == 0) then {
		if (score_A == 100) then {control_A = 1; "title_A" setMarkerColor "ColorBlue"}; // zone cap par Att
		if (score_A == -100) then {control_A = -1; "title_A" setMarkerColor "ColorRed"}; // zone cap par Def
	};
	
	// Zone capé
	if ((control_A == 1) && (score_A <= 0)) then {control_A = 0; "title_A" setMarkerColor "ColorBlack"}; // zone perdu par ATT, devient neutre
	if ((control_A == -1) && (score_A >= 0)) then {control_A = 0; "title_A" setMarkerColor "ColorBlack"}; // zone perdu par DEF, devient neutre
	

	
	// CAP
	
	// Att > Def
	if (score_A < 100) then {
		if ((att_side countside list trigger_A) > (def_side countside list trigger_A)) then {
			_nb_att = ((att_side countside list trigger_A) - (def_side countside list trigger_A));
			score_A = score_A + _nb_att;
			if (score_A > 100) then {score_A = 100}; // on ne dépasse pas 100
		};
	};
	
	// Def > Att
	if (score_A > -100) then {
		if ((def_side countside list trigger_A) > (att_side countside list trigger_A)) then {
			_nb_def = ((def_side countside list trigger_A) - (att_side countside list trigger_A));
			score_A = score_A - _nb_def;
			if (score_A < -100) then {score_A = -100}; // on ne dépasse pas -100
		};
	};
	
	
	
	// Couleur markeur 
	if (score_A < 0) then {  // zone cap par DEF
		_alpha = score_A / -200;  
		"zone_A" setMarkerAlpha _alpha; 
		"zone_A" setMarkerColor "ColorRed"
	};
			
	if (score_A > 0) then {  // zone cap par ATT
		_alpha = score_A / 200;  
		"zone_A" setMarkerAlpha _alpha; 
		"zone_A" setMarkerColor "ColorBlue"
	};
	
	if (score_A == 0) then {  // Neutre invisible.
	"zone_A" setMarkerAlpha 0;
	"title_A" setMarkerColor "ColorBlack";
	};

	
}; 
		




		
//if (((att_side countside list trigger_A) > 0) or ((def_side countside list trigger_A) > 0)) then {hintSilent format["score A = %1", score_A]};			


};